Skip to content

Conversation

pcrane
Copy link
Contributor

@pcrane pcrane commented Sep 23, 2025

Adds a new annotation to point Diffblue Cover to factories that could be used when writing tests for a given method.

For example:

public class ThingFactory {
  public static Thing factory(){
    return new Thing();
  }
}
public class Foo {
  @InTestsUseFactory(className="ThingFactory", methodName="factory")
  public void doThing(Thing t){
    // ...
  }
}

@pcrane pcrane marked this pull request as ready for review September 29, 2025 14:29
@pcrane pcrane self-assigned this Sep 29, 2025
@pcrane pcrane force-pushed the pcrane/feature/intestsusefactory-annotation branch from 7efaa92 to 6935a6c Compare September 29, 2025 14:29
@pcrane pcrane changed the title Add @InTestsUseFactory annotation [TG-21232] Add @InTestsUseFactory annotation Sep 29, 2025
@pcrane pcrane force-pushed the pcrane/feature/intestsusefactory-annotation branch from eae5ee9 to f02e823 Compare September 29, 2025 15:04
@pcrane pcrane requested a review from a team September 29, 2025 15:32
@Retention(RUNTIME)
@Target(METHOD)
@Repeatable(InTestsUseFactory.Repeatable.class)
public @interface InTestsUseFactory {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other annotations are named in the plural so this stands out. We should consider switching to plural naming.

This allows users to add a list of factory methods to supply different arguments to the methods under test.
 This prevents the progress bar from being displayed in the log files.
@pcrane pcrane force-pushed the pcrane/feature/intestsusefactory-annotation branch from f02e823 to 1969e1c Compare September 29, 2025 16:19
@pcrane pcrane merged commit 74be74a into develop Sep 30, 2025
1 check passed
@pcrane pcrane deleted the pcrane/feature/intestsusefactory-annotation branch September 30, 2025 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants